package com.zsc.projectmanagementapi.controller;

import com.github.pagehelper.PageInfo;
import com.zsc.projectmanagementapi.commons.ServerResponse;
import com.zsc.projectmanagementapi.pojo.Do.EmployeeInformation;
import com.zsc.projectmanagementapi.service.EmployeeInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author LinHj
 * @date 2021/6/22 15:07
 **/
@RestController
@RequestMapping("/employeeInformation")
public class EmployeeInformationController {
    @Autowired
    EmployeeInformationService employeeInformationService;

//    @GetMapping("/getInfo")
//    public ServerResponse getInfo(@RequestParam int page,
//                                  @RequestParam int limit,
//                                  @RequestParam(required = false) String name,
//                                  @RequestParam(required = false) Long jobId,
//                                  @RequestParam(required = false) String position){
//        PageInfo<EmployeeInformation> allEmployeeInformation = employeeInformationService.getAllEmployeeInformation(page, limit, name, jobId, position);
//        return ServerResponse.createBySuccess(allEmployeeInformation);
//    }
    @GetMapping("/getInfo")
    public ServerResponse getInfo(
            @RequestParam(required = false) String name,
            @RequestParam(required = false) Long jobId,
            @RequestParam(required = false) String position){
        List<EmployeeInformation> allEmployeeInformation = employeeInformationService.getAllEmployeeInformation(name, jobId, position);
        return ServerResponse.createBySuccess(allEmployeeInformation);
    }
    @PostMapping("/updateInfo")
    public ServerResponse updateInfo(@RequestBody EmployeeInformation employeeInformation){
        int i = employeeInformationService.updateEmployeeInformation(employeeInformation);
        return ServerResponse.createBySuccess(i);
    }

}
